﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="module.ascx.cs" Inherits="ExtraClub.Web.Forms.mail_template.module" %>
<%@ Register Src="~/Modules/Forms/assets/module.ascx" TagName="FormAssets" TagPrefix="extra" %>

<div id="form-container">
</div>
    <script type="text/javascript">
        var YUI = YAHOO.util;
        new YAHOO.inputEx.Form({
            fields: [
			{ inputParams: {
			    label: 'Title',
			    name: 'title',
			    required: true,
			    value: 'title'
			}
			},
			{ inputParams: {
			    label: 'Description',
			    name: 'description',
			    value: 'description'
                }
			},
             { type: 'text',
                 inputParams: {
                     label: 'Body',
                     name: 'body',
                     value: '<p>This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.<\/p>',
                     rows: 8,
                     cols: 140
                 }
             }  
		],
            buttons: [{ type: 'submit', value: 'Change'}],
            parentEl: 'form-container',
            onSubmit: function(e) {
                YUI.Event.stopEvent(e);
                this.showMask();

                var postData = YUI.Lang.JSON.stringify(this.getValue());

                var ws = ExtraClub.Web.Forms.mail_template.service; 
                ws.New(this.getValue().body, function(r) {
                    this.hideMask();
                    console.log(r);
                    $("form-container").set("html", (r));
                } .bind(this));
                return;
            }
        }); /* end */

    </script>

</div>
